package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysSketchMapper;
import com.ruoyi.system.domain.SysSketch;
import com.ruoyi.common.bean.sketch.SysSketchBean;
import com.ruoyi.system.convert.SysSketchConvert;
import com.ruoyi.system.service.ISysSketchService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.bean.BeanUtils;

/**
 * 图文内容Service业务层处理
 * 
 * @author rakic
 * @date 2024-01-26
 */
@Service
public class SysSketchServiceImpl extends ServiceImpl<SysSketchMapper,SysSketch> implements ISysSketchService
{
    @Autowired
    private SysSketchMapper sysSketchMapper;

    /**
     * 查询图文内容
     * 
     * @param sketchId 图文内容主键
     * @return 图文内容
     */
    @Override
    public SysSketchBean selectSysSketchBySketchId(Long sketchId)
    {
        BeanUtils.checkIdsEmpty(sketchId);
        return sysSketchMapper.selectSysSketchBySketchId(sketchId);
    }

    /**
     * 查询图文内容列表
     * 
     * @param sysSketchBean 图文内容
     * @return 图文内容
     */
    @Override
    public List<SysSketchBean> selectSysSketchList(SysSketchBean sysSketchBean)
    {
        return sysSketchMapper.selectSysSketchList(sysSketchBean);
    }

    /**
     * 新增图文内容
     * 
     * @param sysSketchBean 图文内容
     * @return 结果
     */
    @Override
    public int insertSysSketch(SysSketchBean sysSketchBean)
    {
        SysSketch sysSketch = SysSketchConvert.INSTANCE.convert(sysSketchBean);

        sysSketch.setCreateTime(DateUtils.getNowDate());

        return sysSketchMapper.insert(sysSketch);

    }

    /**
     * 修改图文内容
     * 
     * @param sysSketchBean 图文内容
     * @return 结果
     */
    @Override
    public int updateSysSketch(SysSketchBean sysSketchBean)
    {
        SysSketch sysSketch = SysSketchConvert.INSTANCE.convert(sysSketchBean);
        sysSketch.setUpdateTime(DateUtils.getNowDate());
        return sysSketchMapper.updateSysSketch(sysSketch);
    }

    /**
     * 批量删除图文内容
     * 
     * @param sketchIds 需要删除的图文内容主键
     * @return 结果
     */
    @Override
    public int deleteSysSketchBySketchIds(List<Long> sketchIds)
    {
        BeanUtils.checkIdsEmpty(sketchIds);
        return sysSketchMapper.deleteBatchIds(sketchIds);
    }

    /**
     * 删除图文内容信息
     * 
     * @param sketchId 图文内容主键
     * @return 结果
     */
    @Override
    public int deleteSysSketchBySketchId(Long sketchId)
    {
        BeanUtils.checkIdsEmpty(sketchId);
        return sysSketchMapper.deleteById(sketchId);
    }

}
